<!--
 * @Author: ShiJunJie
 * @Date: 2021-09-07 11:13:45
 * @LastEditors  : ShiJunJie
 * @LastEditTime : 2022-05-09 11:19:38
 * @Descripttion: 入口APP文件
-->
<template>
  <a-config-provider :getPopupContainer="getPopupContainer" :locale="locale">
    <RouterView v-slot="{ Component, route }">
      <component :is="Component" :key="route" />
    </RouterView>
  </a-config-provider>
</template>

<script setup>
import { message } from 'ant-design-vue';
import { useThemeStore } from '@/stores/theme';
import enUS from 'ant-design-vue/es/locale/en_US';
import zhCN from 'ant-design-vue/es/locale/zh_CN';
import { LangList } from '@/plugins/components/vue-i18n';

const props = defineProps({
  type: {
    type: String,
    default: 'icon'
  }
});

const { locale: i18n_locale } = useI18n();
const theme = useThemeStore();
const localeMap = { 'zh-CN': zhCN, en: enUS };

const langs = [...LangList];
function handleSubmit(lang) {
  localStorage.setItem('app-locale', lang);
  i18n_locale.value = lang; // 要切换的语言
}

const locale = computed(() => localeMap[i18n_locale.value] || zhCN);

message.config({
  maxCount: 3
});

const getPopupContainer = (el, dialogContext) => {
  if (dialogContext) {
    return dialogContext.getDialogWrap();
  } else {
    return document.body;
  }
};
</script>

<style lang="scss" scoped>
* {
  padding: 0;
  margin: 0;
}
</style>
